//
//  LCVideoAboutViewController.m
//  JKFuYinProject
//
//  Created by admin on 2018/4/20.
//  Copyright © 2018年 LC. All rights reserved.
//


#import "LCVideoAboutViewController.h"

#define kIPhoneX ([UIScreen mainScreen].bounds.size.height == 812.0)
#define LCVideoAboutTableViewCellIdentifier @"LCVideoAboutTableViewCellIdentifier"

@interface LCVideoAboutViewController ()
<UITableViewDelegate, UITableViewDataSource>

@property (nonatomic,strong) UILabel *label;
@property(strong, nonatomic) UITableView *tableView;

@end

@implementation LCVideoAboutViewController

- (void)loadView {
    [super loadView];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.tabBarController.tabBar.translucent = NO;

    if(@available(iOS 11.0, *)) {
        self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:LCVideoAboutTableViewCellIdentifier];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; /** 去掉分割线 */
    self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, 20)];
    [self.view addSubview:_tableView];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        if (@available(iOS 11, *)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
            make.left.right.equalTo(self.view);
        }else{
            make.edges.equalTo(self.view);
        }
    }];
}
- (void)dealloc {
    NSLog(@"__func__dealloc = %s", __func__);
}
#pragma mark - loadData
-(void)setMp4DetailModel:(LCMp4DetailModel *)mp4DetailModel{
    _mp4DetailModel = mp4DetailModel;
    if (_mp4DetailModel) {
        self.arrayData =
        @[
        [NSString stringWithFormat:@"专辑或者作者简介:"],
        [NSString stringWithFormat:@"%@",_mp4DetailModel.detail.content],
        [NSString stringWithFormat:@"专辑或者作者名称:"],
        [NSString stringWithFormat:@"%@",_mp4DetailModel.detail.name],
        [NSString stringWithFormat:@"作者名称:"],
        [NSString stringWithFormat:@"%@",_mp4DetailModel.detail.author],
        [NSString stringWithFormat:@"作品浏览次数:"],
        [NSString stringWithFormat:@"浏览:%@次",_mp4DetailModel.detail.click],
        [NSString stringWithFormat:@"作品点赞次数:"],
        [NSString stringWithFormat:@"点赞:%@次",_mp4DetailModel.detail.zan],
        ];
        [self.tableView reloadData];
    }
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row % 2 == 0) {
        return 40;
    }else {
        if(indexPath.row == 1){
            CGFloat height = [self initWithCheckStrVideoHeigh:self.arrayData[indexPath.row]];
            return height;
        }
        return 35;
    }
}
-(CGFloat)initWithCheckStrVideoHeigh :(NSString * )str
{
    CGFloat a;
    if (ScreenWidth == 320) {
        //5
        a = 13.5;
    }else if(ScreenWidth == 375){
        // 6 7
        a = 14;
    }else {
        //plus
        a = 14.5;
    }
    CGRect labTitleRect = [str boundingRectWithSize:CGSizeMake(ScreenWidth-20, ScreenHeight*9) options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:[NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:a] forKey:NSFontAttributeName] context:nil];
    return labTitleRect.size.height+10;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.arrayData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LCVideoAboutTableViewCellIdentifier forIndexPath:indexPath];
    cell.textLabel.text = self.arrayData[indexPath.row];
    if (indexPath.row % 2 == 0) {
        cell.textLabel.textColor = titleColorLSZ;
        cell.textLabel.font = [LSZSpecialPackaging setlabelTextFontAdaptiveSize:14];
    } else {
        cell.textLabel.font = [LSZSpecialPackaging setlabelTextFontAdaptiveSize:14];
        cell.textLabel.textColor = lightColor;
        if (indexPath.row == 1) {
            cell.textLabel.numberOfLines = 0;
        }
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
- (UITableView *)tableView {
    if (_tableView == nil) {
        CGFloat H = kIPhoneX ? (self.view.bounds.size.height - 64 - 24 - 34) : self.view.bounds.size.height - 64;
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, H) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.bounces = NO;
    }
    return _tableView;
}

@end
